import { createBrowserRouter } from 'react-router-dom'
import Layout from '../pages/Layout'
import Login from '../pages/Login'
import { AuthRoute } from '../components/AuthRoute'
// import Article from '../pages/article'
// import Home from '../pages/Home'
// import Publish from '../pages/Publish'
import { lazy } from 'react'
import { Suspense } from 'react'

const Home = lazy(()=>import('../pages/Home'))
const Publish = lazy(()=>import('../pages/Publish'))
const Article = lazy(()=>import('../pages/article'))

const router = createBrowserRouter([
    {
        path:'/',
        element:  <AuthRoute> <Layout/> </AuthRoute>,
        children:[
            {
                index:true,
                element: <Suspense fallback={'加载中'}><Home></Home></Suspense> 
            },
            {
                path:'article',
                element: <Suspense fallback={'加载中'}><Article></Article></Suspense>
            },
            {
                path:'publish',
                element: <Suspense fallback={'加载中'}><Publish></Publish></Suspense>
            },
        ]  
    },
    {
        path:'/login',
        element:  <Login></Login>
    }
])

export default router